package com.learning.spring.cloud.domain.service.impl;

import com.learning.spring.cloud.domain.model.ProductInventory;
import com.learning.spring.cloud.domain.repo.ProductInventoryRepo;
import com.learning.spring.cloud.domain.service.ProductInventoryService;
import com.learning.spring.cloud.dto.ProductInventoryDto;
import com.learning.spring.cloud.mapper.ProductInventoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ProductInventoryServiceImpl implements ProductInventoryService {
    @Autowired
    private ProductInventoryRepo productInventoryRepo;

    @Override
    public ProductInventoryDto findByProduct(String productCode) {
        ProductInventory inventory = productInventoryRepo.findByProductCode(productCode);
        return ProductInventoryMapper.INSTANCE.toDto(inventory);
    }
}
